
/**
 *  \file att_fsm.h
 *
 *  This file defines state and events related to ATT FSM.
 */

/*
 *  Copyright (C) 2013. Mindtree Ltd.
 *  All rights reserved.
 */

#ifndef _H_ATT_FSM_
#define _H_ATT_FSM_


#if 0
char event_option[] =
"    --------- EVENTS ---------\n\
\n\
    0x81 -> ev_connect_ind    \n\
    0x82 -> ev_disconnect_ind    \n\
    0x01 -> ev_error_rsp    \n\
    0x02 -> ev_exchange_mtu_req    \n\
    0x03 -> ev_exchange_mtu_rsp    \n\
    0xF1 -> ev_att_req    \n\
    0xF2 -> ev_att_rsp    \n\
    0xFF -> ev_unknown_pdu_ind    \n\
    9 -> Exit    \n\
\n\
Your Option - ";
#endif

#ifdef ATT_ON_BR_EDR_SUPPORT
/* Event Defines */
typedef enum
{
    ev_connect_req = 0x80,
    ev_connect_ind = 0x81,
    ev_disconnect_ind = 0x82,
    ev_tx_flow_ind = 0x90,
    ev_error_rsp = 0x01,
    ev_exchange_mtu_req = 0x02,
    ev_exchange_mtu_rsp = 0x03,
    ev_att_req = 0xF1,
    ev_att_rsp = 0xF2,
    ev_unknown_pdu_ind = 0xFF

} EVENTS;
#else /* ATT_ON_BR_EDR_SUPPORT */
/* Event Defines */
typedef enum
{
    ev_connect_ind = 0x81,
    ev_disconnect_ind = 0x82,
    ev_error_rsp = 0x01,
    ev_exchange_mtu_req = 0x02,
    ev_exchange_mtu_rsp = 0x03,
    ev_att_req = 0xF1,
    ev_att_rsp = 0xF2,
    ev_unknown_pdu_ind = 0xFF

} EVENTS;
#endif /* ATT_ON_BR_EDR_SUPPORT */

#define ATT_TX_TRANSACTION_SET_MASK     SL_0_IN_TX_TRANSACTION
#define ATT_RX_TRANSACTION_SET_MASK     SL_0_IN_RX_TRANSACTION
#define ATT_TX_TRANSACTION_RESET_MASK   ((STATE_T)(~(SL_0_IN_TX_TRANSACTION)))
#define ATT_RX_TRANSACTION_RESET_MASK   ((STATE_T)(~(SL_0_IN_RX_TRANSACTION)))
#define ATT_NO_STATE_CHANGE             0xFFFF

#ifdef ATT_ON_BR_EDR_SUPPORT
/* Level 0 State Defines */
typedef enum
{
    SL_0_IDLE = 0x0001,
    SL_0_CONNECTED = 0x0002,
    SL_0_IN_TX_TRANSACTION = 0x0004,
    SL_0_IN_RX_TRANSACTION = 0x0008,
    /**
     * These states are to get CID to Connected state and not used when in
     * Operating State
     */
    SL_0_CONNECTING = 0x0010,
    SL_0_SELF_CONFIGURING = 0x0020,
    SL_0_SELF_CONFIGURED = 0x0040,
    SL_0_PEER_CONFIGURED = 0x0080,
    SL_0_FLOW_OFF = 0x0100

} STATES_LEVEL_0;

#else /* ATT_ON_BR_EDR_SUPPORT */
/* Level 0 State Defines */
typedef enum
{
    SL_0_IDLE = 0x01,
    SL_0_CONNECTED = 0x02,
    SL_0_IN_TX_TRANSACTION = 0x04,
    SL_0_IN_RX_TRANSACTION = 0x08

} STATES_LEVEL_0;
#endif /* ATT_ON_BR_EDR_SUPPORT */

#endif /* _H_ATT_FSM_ */

